home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Transactor
/
Transactor_05_1985_Transactor_Publishing.d64
/
hires listing 4
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2023-02-26
|
2KB
|
76 lines
10 print"[147]":poke 53280,5:poke 53281,0
20 if peek(49152)<>76 then load "hires",8,1
97 :
98 rem initialize variables
99 :
100 hires=12*4096:draw=hi+3:plot=dr+3:move=pl+3:clscr=mo+3:dmode=cl+3
110 selpc=dm+3:colour=se+3:box=co+3:text=bo+3:prnt=te+3:chset=pr+3:trap=ch+3
120 goto 1000
197 :
198 rem plot the graph
199 :
200 x=x+dx:if x>xax then 500
210 sys trap,400 : rem catch any errors in function calculations
220 y=sin(2*x) + cos(3*x) : rem insert function to be graphed here
230 sys trap,450 : rem now catch any plotting errors
240 xp=(x-xin)*sx : rem x-coordinate for plot
250 yp=(y-yin)*sy : rem y-coordinate for plot
260 on pf goto 290,310
267 :
268 rem last point was plotted ok, so draw from last point to current point
269 :
270 sys draw,xp,yp
280 goto 200
287 :
288 rem last point was out of range, so draw from boundary to current point
289 :
290 sys draw,xp,boundary to xp,yp
300 pf=0:goto 200
307 :
308 rem last point was not defined, so just plot the current point
309 :
310 sys plot,xp,yp
320 pf=0:goto 200
397 :
398 rem something went wrong with the function
399 :
400 err=peek(781):pf=2
410 if err=14 then 200 : rem illegal quantity error
420 if err=20 then 200 : rem division by zero error
430 if err=16 then 200 : rem overflow error
440 if err=11 then sys prnt,3,23,"syntax error in function definition":goto 510
445 sys prnt,4,23,"oops! i forgot about error #"+str$(err):goto 510
446 :
447 rem tried to plot out of range. x-coord. should be o.k.
448 rem therefore, just test the y-coord.
449 :
450 err=peek(781):if err<>14 then 445
460 if yp>199 then boundary=199 : rem point is above top of screen
470 if yp<0 then boundary=0 : rem point is below bottom of screen
480 if pf=0 then sys draw,xp-dx,boundary
490 pf=1:goto 200
497 :
498 rem end by pressing <return>
499 :
500 sys prnt,13,23,"graph completed"
510 get a$:if a$<> chr$(13) then 510
520 end
997 :
998 rem begin the show
999 :
1000 xin=-2*(NULL) : rem minimum value for x
1010 xax= 2*(NULL) : rem maximum value for x
1020 yin=-3.0 : rem minimum value for y
1030 yax= 3.0 : rem maximum value for y
1040 sx=160/(xax-xin) : rem scale in x direction
1050 sy=200/(yax-yin) : rem scale in y direction
1060 dx= (xax-xin)/160 : rem set increment for 160 point plot
1070 pf=2 : rem initialize plotting flag
1080 rem pf=0 ... last point calculated was plotted o.k.
1090 rem pf=1 ... last point calculated was out of range
1100 rem pf=2 ... last point calculated was undefined
1110 x=xin - dx : rem initialize x
1120 sys hires,1,0,1,0,1
1130 sys dmode,1:sys selpc,1
1140 goto 200